<template>
  <div>
    <!-- 使用Header组件 -->
    <HeaderComponent 
      :isLoggedIn="userStore.isLoggedIn"
      :userInfo="userStore.userInfo"
      :showUserPanel="showUserPanel"
      @toggle-user-panel="toggleUserPanel"
      @logout="handleLogout"
    />
    
    <div class="discounts-page">
      <div class="discounts-header">
        <h1>我的优惠券</h1>
      </div>
      
      <div class="discounts-tabs">
        <div class="tab active">未使用</div>
        <div class="tab">已使用</div>
        <div class="tab">已过期</div>
      </div>
      
      <div class="discounts-list">
        <!-- 空状态 -->
        <div class="empty-state">
          <div class="empty-icon">🎟️</div>
          <div class="empty-text">暂无可用优惠券</div>
          <div class="empty-subtext">优惠券仅支持在Web、Android端使用</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import HeaderComponent from '../components/HeaderComponent.vue';
import { useUserStore } from '../stores/user.js';

export default {
  name: 'MyDiscounts',
  components: {
    HeaderComponent
  },
  setup() {
    const userStore = useUserStore();
    return {
      userStore
    }
  },
  data() {
    return {
      showUserPanel: false
    }
  },
  methods: {
    toggleUserPanel() {
      this.showUserPanel = !this.showUserPanel;
    },
    handleLogout() {
      this.userStore.logout();
      this.$router.push('/');
    }
  }
}
</script>

<style scoped>
.discounts-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
  background-color: #f4f5f5;
  min-height: 100vh;
}

.discounts-header {
  margin-bottom: 24px;
}

.discounts-header h1 {
  font-size: 24px;
  color: #1d2129;
  margin: 0;
}

.discounts-tabs {
  display: flex;
  margin-bottom: 16px;
}

.tab {
  padding: 12px 24px;
  font-size: 14px;
  color: #86909c;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: #1e80ff;
  border-bottom-color: #1e80ff;
}

.discounts-list {
  background: white;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.empty-state {
  text-align: center;
  padding: 60px 0;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-text {
  font-size: 16px;
  color: #1d2129;
  margin-bottom: 8px;
}

.empty-subtext {
  font-size: 14px;
  color: #86909c;
}
</style>